#!/usr/bin/env python
# encoding: utf-8
"""
@author:zwb
@file: func.py
@contact: zwb15083976291@163.com
@time: 2021/11/14
"""

# 获取枚举值
from collections import Iterable

from django.core.exceptions import ValidationError
from django.core.validators import URLValidator


def get_enum_value(enum_class, value):
    for item in enum_class.__members__.items():
        if str(item[1].value[0]) == str(value):
            return item[1].value[-1]


# 判断是否为url
def whether_url(value):
    try:
        URLValidator()(value)
        return True
    except ValidationError as e:
        return False


